#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<stack>
#include<vector>
using namespace std;
bool IsPopOrder(vector<int>& pushV, vector<int>& popV) {
    if (pushV.size() != popV.size())
        return false;
    stack<int> st;
    int i = 0;
    int j = 0;
    while(i<pushV.size())
    { 
        st.push(pushV[i++]);
        while (!st.empty() && st.top() == popV[j])
        {
            st.pop();
            j++;
        }
    }
    return st.empty();
}
int main()
{
    vector<int> v1 = { 1,2,3,4,5 };
    vector<int> v2 = { 4,5,3,2,1 };
    cout << IsPopOrder(v1, v2) << endl;
    return 0;
}
